package com.wfl.sampling.service;

import com.wechat.pay.contrib.apache.httpclient.auth.Verifier;
import com.wfl.sampling.entity.WxchatOrderInformation;
import com.wfl.sampling.entity.WxchatPreOrder;
import com.wfl.sampling.entity.WxchatRefundInformation;
import com.wfl.sampling.handler.PayInRequestinfo;
import com.wfl.sampling.handler.WxChatPayResponseInfo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SignatureException;
import java.security.spec.InvalidKeySpecException;
import java.util.List;
import java.util.Map;

public interface WxPayService {

    //发起预下单请求并返回结果
    WxChatPayResponseInfo unifiedOrder(PayInRequestinfo payInRequestinfo, HttpServletRequest request) throws IOException, NoSuchAlgorithmException, SignatureException, InvalidKeyException, InvalidKeySpecException;

    //验证回调支付通知签名
    String verifySignatureOrder(HttpServletRequest request, HttpServletResponse response, Verifier verifier) throws IllegalAccessException;

    //用于申请退款并返回结果


    //用于查询支付结果并返回
    WxchatOrderInformation queryOrder(String out_trade_no) throws MalformedURLException, UnsupportedEncodingException, URISyntaxException, NoSuchAlgorithmException, SignatureException, InvalidKeySpecException, InvalidKeyException;


    //关闭订单
    Map<String,Integer> Closeorder(String out_trade_no) throws UnsupportedEncodingException, NoSuchAlgorithmException, SignatureException, InvalidKeySpecException, InvalidKeyException;

    //用于申请退款
    String refund(String param) throws UnsupportedEncodingException, NoSuchAlgorithmException, SignatureException, InvalidKeySpecException, InvalidKeyException;

    //验证退款通知回调签名
    String verifySignatureRefund(HttpServletRequest request, HttpServletResponse response, Verifier verifier) throws IllegalAccessException;

    //用于查询退款并返回
    WxchatRefundInformation queryRefund(String out_trade_no) throws MalformedURLException, UnsupportedEncodingException, URISyntaxException, NoSuchAlgorithmException, SignatureException, InvalidKeySpecException, InvalidKeyException;

   //查询预下单列表并返回
    List<WxchatPreOrder> findPreOrders(int user_id);

    //查询订单列表并返回
    List<WxchatOrderInformation> findOrders(int user_id);

    //查询退款列表并返回
    List<WxchatRefundInformation> findRefunds(int user_id);
}
